package com.atguigu.edu.realtime.utils;

/**
 * @author Felix
 * @date 2022/11/7
 * 操作MySQL的工具类
 */
public class MySqlUtil {
    //获取从MySQL字典表中读取数据并创建动态表的建表语句
    public static String getBaseDicLookUpDDL() {
        return "CREATE TABLE base_dic (\n" +
            " dic_code string,\n" +
            " dic_name string\n" +
            ") " + mysqlLookUpTableDDL("base_dic");
    }

    //获取JDBC连接器相关连接属性
    public static String mysqlLookUpTableDDL(String tableName) {
        return "WITH (\n" +
            "   'connector' = 'jdbc',\n" +
            "   'url' = 'jdbc:mysql://hadoop101:3306/edu',\n" +
            "   'driver' = 'com.mysql.cj.jdbc.Driver',\n" +
            "   'username' = 'root',\n" +
            "   'password' = '000000',\n" +
            "   'table-name' = '" + tableName + "',\n" +
            "   'lookup.cache.max-rows' = '500',\n" +
            "   'lookup.cache.ttl' = '1 hour'\n" +
            ")";
    }
}
